/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedBean.TX.tta;

import session.TX.PIPBeanRemote;
import managedBean.TX.CustomerIOTRPortal.FakeMainPortalMB;
import entity.PurchasedItem_Regular;
import Helper.TTAHelper.Helper_PIPSales;
import java.util.Calendar;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author Lu Xiaodi
 */
@ManagedBean(name = "ompipManagedBean")
@SessionScoped
public class OMPIPMB {

    @EJB
    PIPBeanRemote pipBean;
    @ManagedProperty(value = "#{fakeMainPortalMB}")
    private FakeMainPortalMB portalManagedBean;
    Calendar start;
    Calendar end;

    /** Creates a new instance of OMPIPMB */
    public OMPIPMB() {
    }
    
    public List<Calendar> getAvailableMonths(){
        return pipBean.getAvailableMonths();
    }

    public List<PurchasedItem_Regular> getSalesReportItems() {
        start = Calendar.getInstance();
        start.set(2010, 9, 01, 0, 0, 0);
        end = Calendar.getInstance();
        end.set(2011, 10, 01, 23, 59, 59);
        return pipBean.getSalesReportItems(portalManagedBean.getOutletId(), start, end);
    }
    
    public List<Helper_PIPSales> getSales(){
        start = Calendar.getInstance();
        start.set(2010, 10, 01, 0, 0, 0);
        end = Calendar.getInstance();
        end.set(2011, 10, 01, 23, 59, 59);
        return pipBean.getSalesData(portalManagedBean.getOutletId(), start, end);
    }

    public Calendar getEnd() {
        return end;
    }

    public void setEnd(Calendar end) {
        this.end = end;
    }

    public Calendar getStart() {
        return start;
    }

    public void setStart(Calendar start) {
        this.start = start;
    }

    public FakeMainPortalMB getPortalManagedBean() {
        return portalManagedBean;
    }

    public void setPortalManagedBean(FakeMainPortalMB portalManagedBean) {
        this.portalManagedBean = portalManagedBean;
    }
}
